package io.github.yangyouwang.module.app.controller;

import io.github.yangyouwang.common.base.CrudController;
import io.github.yangyouwang.module.mm.entity.GridAndFixRatioSymbolInfo;
import io.github.yangyouwang.module.mm.service.FutureSymbolCurrentPriceService;
import io.github.yangyouwang.module.mm.entity.FutureSymbolCurrentPrice;
import io.github.yangyouwang.module.mm.service.GridAndFixRatioService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Api(tags = "测试用")
@Controller
@RequestMapping("/test")
public class TestController extends CrudController {

    @Autowired
    private FutureSymbolCurrentPriceService futureSymbolCurrentPriceService;

    @Autowired
    private GridAndFixRatioService gridAndFixRatioService;

    @GetMapping("/getByLimitDatetime/{symbol}/{currentDatetime}")
    @ResponseBody
    public FutureSymbolCurrentPrice getByLimitDatetime(@Valid @NotNull(message = "symbol不能为空") @PathVariable String symbol, @Valid @NotNull(message = "时间不能为空") @PathVariable String currentDatetime) {
        return futureSymbolCurrentPriceService.getByLimitDatetime(symbol, currentDatetime);
    }

    @GetMapping("/getTradeSymbol/{datetime}/{currentBalance}/{excludeSymbols}")
    @ResponseBody
    public GridAndFixRatioSymbolInfo getTradeSymbol(@Valid @NotNull(message = "时间不能为空") @PathVariable String datetime, @Valid @NotNull(message = "当前余额不能为空") @PathVariable Double currentBalance,
                                                    @PathVariable String excludeSymbols) {
        return gridAndFixRatioService.getTradeSymbol(datetime, currentBalance, excludeSymbols);
    }

}
